package com.baselibrary.view.banner.loader;

import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;

import com.baselibrary.R;
import com.baselibrary.utils.GlideLoader;
import com.bumptech.glide.Glide;

import java.io.File;

/**
 * Created by Administrator on 2018/8/6.
 */

public class GlideImageLoader extends ImageLoader {

    private static final long serialVersionUID = 2912907786800194156L;
    private int mImageType;

    public GlideImageLoader(int imageType) {
        this.mImageType = imageType;
    }

    @Override
    public void displayImage(Context context, Object path, ImageView imageView) {
        //Glide 加载图片简单用法
        String url = (String) path;
        if (mImageType == 1) {
            if (url.startsWith("http")) {
                GlideLoader.LoderImage(context, url, imageView);
            } else {
                Glide.with(context).load(Uri.fromFile(new File(url)))
                        .into(imageView);
            }
        } else if (mImageType == 2) {
            GlideLoader.loadBannerImage(context, url, imageView);
        } else if (mImageType == 3) {
            GlideLoader.LoderImage(context, url, imageView, 6);
        } else if (mImageType == 4) {
            GlideLoader.LoadRoundCornerImage(context, url, imageView);
        } else if (mImageType == 5) {
            GlideLoader.LoderLoadReleaseCoverImagePlaceholder(context, url, imageView, 8, R.drawable.img_poster_three_bg_top);
        } else {
            GlideLoader.LoderCircleImage(context, url, imageView);
        }
    }
}
